package com.ikas.ai.server.module.instance.dorisDao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ikas.ai.server.module.instance.model.DorisWorkFlowInstance;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 工况转换流程实例表
 *
 * @author hu.bowei
 * @email hu.bowei@ikasinfo.com
 * @date 2023-05-06 17:12:07
 */
@Mapper
public interface DorisWorkFlowInstanceDao extends BaseMapper<DorisWorkFlowInstance> {

    @Select("SELECT * FROM ( SELECT id,machine_no,next_wc,wf_name, ROW_NUMBER() OVER ( PARTITION BY machine_no ORDER BY start_time DESC ) AS row_num FROM t_work_flow_instance ) AS ranked WHERE row_num = 1")
    List<DorisWorkFlowInstance> selectByMachineNo();
}
